package 网络通信1;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;

public class Servern {
	public static void main(String[] args) throws Exception
	{
		System.out.println("服务端启动成功");
		DatagramSocket socket=new DatagramSocket(6666);
		byte[] buffer=new byte[1024*64];
		DatagramPacket packet=new DatagramPacket(buffer,buffer.length);
		while(true) {
			socket.receive(packet);
			int len=packet.getLength();
			System.out.println(new String(buffer,0,len));
			System.out.println("----------------------");
		}
	}
}